var hx = require("hbuilderx");
const { exec } = require('child_process');
const {getTheme} = require('./utils/asset.js')


//该方法将在插件激活的时候调用
function activate(context) {
    let webviewPanel = hx.window.createWebView("extensions.treedemo",{
        enableScripts:true
    });
    console.log(getTheme(), '123')
    const workspace = hx.workspace.getWorkspaceFolders()
    
    workspace.then(folders => {
        
    })
    
    let webview = webviewPanel.webView;
    webview.html = `
        <html>
            <head>
                <style>
                    html,body,p{
                        padding: 0;
                        margin: 0;
                        box-sizing: border-box;
                        font-size: 13px;
                    }
                    .git-window{
                        display: flex;
                        flex-direction: column;
                        font-size: 12px;
                        height: 100vh;
                        background-color: #faf6e6;
                    }
                    
                    .git-status{
                        flex: 0 0 40px;
                        box-sizing: border-box;
                        padding: 10px 20px;
                        border-top: 1px solid #dedede;
                    }
                    
                    .git-main{
                        flex: 0 0 calc(100% - 40px);
                        box-sizing: border-box;
                    }
                    
                    .git-type-name{
                        line-height: 1.8em;
                    }
                    .git-file-box{
                        line-height: 1.8em;
                    }
                    .fox-icon {
                       font-size: 16px;
                    }
                    .flex-space-between{
                        display: flex;
                        justify-content: space-between;
                    }
                    .flex{
                        display: flex;
                    }
                    .workspace-icon-item{
                        margin: 0 5px;
                    }
                </style>
            </head>
            <body>
                <div class="git-window" id="app">
                    <div class="git-main">
                        <div class="git-workspace-item" v-for="item in data" :key="item.id">
                            <div class="git-workspace-title flex-space-between">
                                <p>{{item.name}}</p>
                                <div class="flex">
                                    <div class="workspace-icon-item">
                                        <svg class="fox-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2883" width="20" height="20">
                                            <path d="M497.066667 832c-76.8 0-153.6-27.733333-213.333334-81.066667-64-57.6-100.266667-136.533333-104.533333-221.866666S204.8 362.666667 260.266667 298.666667c57.6-64 136.533333-100.266667 221.866666-104.533334 85.333333-4.266667 166.4 25.6 230.4 81.066667 29.866667 25.6 53.333333 57.6 70.4 91.733333 6.4 10.666667 2.133333 23.466667-8.533333 27.733334-10.666667 4.266667-23.466667 2.133333-27.733333-8.533334-14.933333-29.866667-36.266667-57.6-61.866667-78.933333-57.6-51.2-128-76.8-202.666667-72.533333-74.666667 4.266667-142.933333 36.266667-192 91.733333s-74.666667 125.866667-70.4 200.533333c4.266667 74.666667 36.266667 142.933333 91.733334 192 113.066667 102.4 290.133333 93.866667 392.533333-21.333333 17.066667-19.2 29.866667-38.4 42.666667-61.866667 4.266667-10.666667 17.066667-14.933333 27.733333-8.533333 10.666667 4.266667 14.933333 17.066667 8.533333 27.733333-12.8 25.6-29.866667 49.066667-49.066666 70.4-61.866667 70.4-149.333333 106.666667-236.8 106.666667z" fill="#333333" p-id="2884"></path>
                                            <path d="M825.6 339.2l-8.533333 115.2c-2.133333 14.933333-17.066667 23.466667-32 17.066667L682.666667 416c-14.933333-8.533333-14.933333-29.866667 0-36.266667l110.933333-59.733333c14.933333-8.533333 34.133333 2.133333 32 19.2z" fill="#333333" p-id="2885"></path>
                                            </svg>
                                    </div>
                                    <div class="workspace-icon-item">
                                        <svg class="fox-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9305" width="20" height="20">
                                            <path d="M890.3 218.6L374.1 734.7 133.7 494.3l-35.4 35.4 275.8 275.7 551.6-551.5z" fill="#333333" p-id="9306"></path>
                                            </svg>
                                    </div>
                                    <div class="workspace-icon-item">
                                        <svg class="fox-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6850" width="17" height="17"><path d="M532.48 256v256c0 7.168-3.072 13.312-8.192 16.384l-131.072 92.16c-4.096 3.072-8.192 4.096-12.288 4.096-6.144 0-12.288-3.072-16.384-8.192-6.144-9.216-4.096-22.528 5.12-28.672L491.52 501.76V256c0-11.264 9.216-20.48 20.48-20.48s20.48 9.216 20.48 20.48z m269.312-102.4H952.32c11.264 0 20.48-9.216 20.48-20.48s-9.216-20.48-20.48-20.48H747.52c-11.264 0-20.48 9.216-20.48 20.48v204.8c0 11.264 9.216 20.48 20.48 20.48s20.48-9.216 20.48-20.48V179.2C871.424 258.048 931.84 380.928 931.84 512c0 231.424-188.416 419.84-419.84 419.84S92.16 743.424 92.16 512 280.576 92.16 512 92.16c11.264 0 20.48-9.216 20.48-20.48s-9.216-20.48-20.48-20.48C258.048 51.2 51.2 258.048 51.2 512s206.848 460.8 460.8 460.8 460.8-206.848 460.8-460.8c0-139.264-63.488-271.36-171.008-358.4z" p-id="6851" fill="#333333"></path>
                                        </svg>
                                    </div>
                                    <div class="workspace-icon-item">
                                        <svg class="fox-icon" height="20"  width="28" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="20880">
                                            <path d="M533.333333 469.333333c35.413333 0 64 28.586667 64 64s-28.586667 64-64 64-64-28.586667-64-64 28.586667-64 64-64z m-213.333333 0c35.2 0 64 28.586667 64 64S355.413333 597.333333 320 597.333333 256 568.746667 256 533.333333 284.586667 469.333333 320 469.333333z m426.666667 0c35.413333 0 64 28.586667 64 64s-28.586667 64-64 64-64-28.586667-64-64 28.586667-64 64-64z" fill="#333333" p-id="20881"></path>
                                            </svg>
                                    </div>
                                </div>
                            </div>
                            <div class="git-commit-input">
                                <textarea v-model="item.commitInfo"></textarea>
                            </div>
                            <div>
                                <div v-for="v in item.items" :key="item.title">
                                    <p class="git-type-name">{{v.title}}</p>
                                    <div>
                                        <template v-for="f in v.children">
                                            <div :key="f.file" class="git-file-box">
                                                <p>{{f.file}}</p>
                                            </div>
                                        </template>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="git-status">
                        <div>
                            <div>
                                <svg class="fox-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10284" width="20" height="20">
                                    <path d="M704 192c-77.2 0-140 62.8-140 140 0 66.8 47.4 123.8 111.8 137-2.4 38.2-20.6 58.6-54 84.4-40.8 31.4-93.4 40-130.6 46.8-81.4 14.8-125.8 54-145 80V341.6c30-5.6 57.4-21 78-43.8 23.2-25.8 36-59 36-93.8 0-77.2-62.8-140-140-140s-140 62.8-140 140c0 34 12.4 66.6 34.6 92.2 19.8 22.6 46.2 38.2 75.4 44.6v342.6c-29 6.4-55.6 22-75.4 44.6C192.4 753.4 180 786 180 820c0 77.2 62.8 140 140 140s140-62.8 140-140c0-46.8-23.2-89.8-61.4-115.8 17.2-19.4 49-39.2 102.2-48.8 43.2-7.8 105.2-19.2 154.8-57.6 47.2-36.4 73.4-73 76-128.6 64.6-13 112.2-70.2 112.2-137.2 0.2-77.2-62.6-140-139.8-140z m-468 12c0-46.4 37.6-84 84-84s84 37.6 84 84-37.6 84-84 84-84-37.6-84-84z m168 616c0 46.4-37.6 84-84 84s-84-37.6-84-84 37.6-84 84-84 84 37.6 84 84z m300-404c-46.4 0-84-37.6-84-84s37.6-84 84-84 84 37.6 84 84-37.6 84-84 84z" p-id="10285" fill="#333333"></path>
                                </svg>
                                <span>master</span>
                            </div>
                        </div>
                    </div>
                </div>
            </body>
            <script src="https://cdn.jsdelivr.net/npm/vue"></script>
            <script>
                
                const app = new Vue({
                    data:{
                        data: [
                            {
                                id: 1,
                                name: '项目一',
                                commitInfo: '',
                                items: [
                                    {
                                        title: '暂存的更改',
                                        children: [
                                            {
                                                file: 'E://hbx/gitManager/html/main.html',
                                            }
                                        ]
                                    },
                                    {
                                        title: '更改',
                                        children: [
                                            {
                                                file: 'E://hbx/gitManager/utils/git.js',
                                            }
                                        ]
                                    }
                                ],
                            },
                            {
                                id: 2,
                                name: '项目二',
                                commitInfo: '',
                                items: [
                                    {
                                        title: '暂存的更改',
                                        children: [
                                            {
                                                file: 'E://hbx/gitManager/html/main.html',
                                            }
                                        ]
                                    },
                                    {
                                        title: '更改',
                                        children: [
                                            {
                                                file: 'E://hbx/gitManager/utils/git.js',
                                            }
                                        ]
                                    }
                                ],
                            },
                        ]
                    },
                    methods: {
                        
                    } 
                }).$mount('#app')
            </script>
        </html>
    `;
	
}
//该方法将在插件禁用的时候调用（目前是在插件卸载的时候触发）
function deactivate() {

}
module.exports = {
	activate,
	deactivate
}
